<template>
  <div>
    <el-input :disabled="disabled" v-model="flowInfoLabel" />
  </div>
</template>

<script>
export default {
  name: 'FlowInfo',
  inject: ['getDataFromOthers'],
  props: {
    disabled: {
      type: Boolean,
      default: true
    },
    modelValue: {
      type: String,
      default: ''
    },
    flowParam: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      flowInfo: {}
    };
  },
  computed: {
    flowInfoLabel() {
      return this.flowInfo[this.flowParam] ?? '-';
    }
  },
  watch: {
    modelValue: {
      handler(newVal) {
        if (newVal) {
          this.flowInfo = newVal;
        }
      },
      immediate: true,
      deep: true
    },
    flowInfo: {
      handler(newVal) {
        this.$emit('update:modelValue', newVal);
      },
      deep: true,
      immediate: true
    }
  },
  mounted() {
    if (this.getDataFromOthers && typeof this.getDataFromOthers == 'function' && this.getDataFromOthers() && this.getDataFromOthers().starter) {
      this.flowInfo = this.getDataFromOthers().params;
    }
  },
  methods: {}
};
</script>
